library("plyr",lib.loc="~/myOwnRPackage")

#reviewer data for rq2
review_mon<-read.table("reviewCnt_perMonth.res",head=T,sep=",")
names(review_mon)<-c("reviewer","month","reviewCnt_mon")
review_mon<-ddply(review_mon,.(reviewer),transform,total_reviews=sum(reviewCnt_mon),monCnt=length(reviewCnt_mon))

reviewBot<-c("mesos-review","aurorabot","asfbot","mesos-review-windows")
nrow(review_mon)
review_mon<-review_mon[!(review_mon$reviewer %in% reviewBot),]
nrow(review_mon)

write.table(review_mon,file="rq2_review_base_dat.res",sep=",",col.names=T,row.names=F)

###request submitters for rq3
b<-read.table("user_requestCnt_created.res",head=T,sep=",")
names(b)<-c("submitter","created_mon","requestCnt_createdMon")
b<-ddply(b,.(submitter),transform,total_requests=sum(requestCnt_createdMon),monCnt=length(created_mon))
b<-ddply(b,.(submitter,created_mon),transform,modi_mon=paste("01-",created_mon,sep=""))
submitter_mon<-ddply(b,.(submitter),summarize,max_mon=max(as.Date(modi_mon,"%d-%m-%Y")),min_mon=min(as.Date(modi_mon,"%d-%m-%Y")))

submitter_mon$active_days<-as.numeric(submitter_mon$max_mon-submitter_mon$min_mon)
submitter_mon$active_mons<-as.numeric((submitter_mon$max_mon-submitter_mon$min_mon)/30)
b<-merge(b,submitter_mon,by="submitter")

write.table(b,file="rq3_submitter_base_dat.res",sep=",",col.names=T,row.names=F)
